<?php

namespace App\Providers;

use Elasticsearch\ClientBuilder;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        $this->registerEsService();
    }

    protected function registerEsService()
    {
        $this->app->singleton('es',function(){
            $host = [
                'elasticsearch:9200'
            ];

            return ClientBuilder::create()->setHosts($host)->build();
        });
    }
}
